home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
program
/
oxcc1434.zip
/
SRC
/
BINIMG.H
next >
Wrap
C/C++ Source or Header
|
1995-11-01
|
61KB
|
1,557 lines
/* binimg.h -- defs for a.out+coff+elf+pe+exe+ne+le+omf formats */
#ifndef __GNUC__
#pragma pack(1)
#define __attribute__()
#endif
/* ****************** MAGIC NUMBERS ************************ */
#define OBJMAGIC 0x80 /* omf THEADR record type, first byte */
#define LIBMAGIC 0xF0 /* omf LIBR first byte */
#define ARMAGIC 0x3c21 /* !< beginning of unix style archive */
#define OMAGIC 0x0107 /* a.out object file 0407 */
#define NMAGIC 0x0108 /* a.out pure executable 0410 */
#define ZMAGIC 0x010b /* a.out demand paged executable 0413 */
#define IMAGIC 0x014c /* coff header f_magic for i386 */
#define AIXMAGIC 0x0175 /* coff header f_magic for aix i386 */
#define MIBMAGIC 0x0162 /* coff header f_magic for mips big endian R3000 */
#define MI3MAGIC 0x0162 /* coff header f_magic for mips little endian R3000 */
#define MI4MAGIC 0x0166 /* coff header f_magic for mips little endian R4000 */
#define MI1MAGIC 0x0166 /* coff header f_magic for mips little endian R10000 */
#define AL1MAGIC 0x0184 /* coff header f_magic for Alpha AXP */
#define AL2MAGIC 0x0186 /* coff header f_magic for Alpha APX */
#define M68MAGIC 0x0268 /* coff header f_magic for M68000 series */
#define PPCMAGIC 0x01f0 /* coff header f_magic for PowerPC little endian */
#define PAMAGIC 0x0290 /* coff header f_magic for HP PA RISC */
#define DOSMAGIC 0x5A4D /* MZ start of .exe files */
#define NEMAGIC 0x454E /* NE os2,win31 16bit */
#define LEMAGIC 0x454C /* LE os2,vxd 32 bit */
#define PEMAGIC 0x4550 /* PE nt,win95,win32s */
#define NTMAGIC 0x010b /* NT OPTIONAL HEADER */
#define ROMMAGIC 0x0107 /* NT ROM OPTIONAL HEADER */
#define OPOMAGIC 0x0104 /* coff optional header object file, as output */
#define OPZMAGIC 0x010b /* coff optional header demand load format, ld output */
#define OPTMAGIC 0x0101 /* coff optional header target shared library */
#define OPHMAGIC 0x0123 /* coff optional header host shared library */
#define ELFMAGIC 0x457f /* beginning of elf ident "\177ELF" */
/* ********************* FILE HEADERS *************************** */
#define NEW_EXECUTABLE(ptr) (ptr->e_lfarlc >= 0x0040)
typedef struct { /* DOS .EXE header */
unsigned short e_magic; /* 00 Magic number */
unsigned short e_cblp; /* 02 Bytes on last page of file */
unsigned short e_cp; /* 04 Pages in file */
unsigned short e_crlc; /* 06 Relocations */
unsigned short e_cparhdr; /* 08 Size of header in paragraphs */
unsigned short e_minalloc; /* 0A Minimum extra paragraphs needed */
unsigned short e_maxalloc; /* 0C Maximum extra paragraphs needed */
unsigned short e_ss; /* 0E Initial (relative) SS value */
unsigned short e_sp; /* 10 Initial SP value */
unsigned short e_csum; /* 12 Checksum */
unsigned short e_ip; /* 14 Initial IP value */
unsigned short e_cs; /* 16 Initial (relative) CS value */
unsigned short e_lfarlc; /* 18 File address of relocation table */
unsigned short e_ovno; /* 1A Overlay number */
unsigned short e_res[4]; /* 1C Reserved words */
unsigned short e_oemid; /* 24 OEM identifier (for e_oeminfo) */
unsigned short e_oeminfo; /* 26 OEM information; e_oemid specific */
unsigned short e_res2[10]; /* 28 Reserved words */
long e_lfanew __attribute__((packed)); /* 3C File address of new exe header */
} DOS_HDR, *PDOS_HDR;
typedef struct { /* OS/2 .EXE header */
unsigned short ne_magic; /* Magic number */
char ne_ver; /* Version number */
char ne_rev; /* Revision number */
unsigned short ne_enttab __attribute__((packed));/* Offset of Entry Table */
unsigned short ne_cbenttab; /* Number of bytes in Entry Table */
long ne_crc __attribute__((packed)); /* Checksum of whole file */
unsigned short ne_flags; /* Flag word */
unsigned short ne_autodata; /* Automatic data segment number */
unsigned short ne_heap; /* Initial heap allocation */
unsigned short ne_stack; /* Initial stack allocation */
long ne_csip __attribute__((packed)); /* Initial CS:IP setting */
long ne_sssp; /* Initial SS:SP setting */
unsigned short ne_cseg; /* Count of file segments */
unsigned short ne_cmod; /* Entries in Module Reference Table */
unsigned short ne_cbnrestab; /* Size of non-resident name table */
unsigned short ne_segtab; /* Offset of Segment Table */
unsigned short ne_rsrctab; /* Offset of Resource Table */
unsigned short ne_restab; /* Offset of resident name table */
unsigned short ne_modtab; /* Offset of Module Reference Table */
unsigned short ne_imptab; /* Offset of Imported Names Table */
long ne_nrestab __attribute__((packed)); /* Offset of Non-resident Names Table */
unsigned short ne_cmovent; /* Count of movable entries */
unsigned short ne_align; /* Segment alignment shift count */
unsigned short ne_cres; /* Count of resource segments */
unsigned char ne_exetyp; /* Target Operating system */
unsigned char ne_flagsothers; /* Other .EXE flags */
unsigned short ne_pretthunks __attribute__((packed)); /* offset to return thunks */
unsigned short ne_psegrefbytes; /* offset to segment ref. bytes */
unsigned short ne_swaparea; /* Minimum code swap area size */
unsigned short ne_expver; /* Expected Windows version number */
} OS2_HDR, *POS2_HDR;
typedef struct { /* WIN31 .EXE header */
unsigned short ne_magic; /* Magic number */
char ne_ver; /* Version number */
char ne_rev; /* Revision number */
unsigned short ne_enttab __attribute__((packed));/* Offset of Entry Table */
unsigned short ne_cbenttab; /* Number of bytes in Entry Table */
long ne_crc __attribute__((packed)); /* Checksum of whole file */
unsigned short ne_flags; /* Flag word */
unsigned short ne_autodata; /* Automatic data segment number */
unsigned short ne_heap; /* Initial heap allocation */
unsigned short ne_stack; /* Initial stack allocation */
long ne_csip __attribute__((packed)); /* Initial CS:IP setting */
long ne_sssp; /* Initial SS:SP setting */
unsigned short ne_cseg; /* Count of file segments */
unsigned short ne_cmod; /* Entries in Module Reference Table */
unsigned short ne_cbnrestab; /* Size of non-resident name table */
unsigned short ne_segtab; /* Offset of Segment Table */
unsigned short ne_rsrctab; /* Offset of Resource Table */
unsigned short ne_restab; /* Offset of resident name table */
unsigned short ne_modtab; /* Offset of Module Reference Table */
unsigned short ne_imptab; /* Offset of Imported Names Table */
long ne_nrestab __attribute__((packed)); /* Offset of Non-resident Names Table */
unsigned short ne_cmovent; /* Count of movable entries */
unsigned short ne_align; /* Segment alignment shift count */
unsigned short ne_cres; /* Count of resource segments */
unsigned char ne_exetyp; /* Target Operating system */
unsigned char ne_flagsothers; /* Other .EXE flags */
unsigned short ne_fastload __attribute__((packed)); /* ofs in sectors to fast load area */
unsigned short ne_fastsize; /* size in sectors of fast load area */
unsigned short ne_swaparea; /* reserved */
unsigned short ne_expver; /* Expected Windows version number */
} WIN31_HDR, *PWIN31_HDR;
typedef struct { /* Windows VXD header */
unsigned short e32_magic; /* Magic number */
unsigned char e32_border; /* The byte ordering for the VXD */
unsigned char e32_worder; /* The word ordering for the VXD */
unsigned long e32_level __attribute__((packed));